|
To avoid redundant definition of attributes and methods which are commonly needed by several classes, they can be factored out into a parent class and then be inherited by derived classes. The parent classes of a derived class are often called ancestors. In a derived class, additional attributes and methods can be declared, as well as inherited methods can be redefined. Assume for example we need two new counters which extend/modify the functionality of the counter of the last section. One of the counters the up_down_counter has the additional functionality to count down while an address_counter redefines the count_up-function. The new version of count_up will increment the value of address_counter by four. |
In UML notation, inherited attributes and methods are not displayed explicitly. They are implicitly available. The symbol for the inheritance relationship is a triangle
Corresponding to the derived classes the state diagram which was shown in the last chapter has to be extended. |